public class Solution {
    public int jump(int[] nums) {
        int left = 0, right = 0, ret = 0, maxPos = 0, n = nums.length;
        while(true){
            if(maxPos >= n-1){
                return ret;
            }
            for(int i = left; i <= right; i++){
                maxPos = Math.max(maxPos, nums[i] + i);
            }
            left = right + 1;
            right = maxPos;
            ret++;
        }
    }
}
